package com.lottery.ruok.lottrey.chat.model.prize;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;

import com.lottery.ruok.lottrey.R;
import com.lottery.ruok.lottrey.activity.LoginActivity;
import com.lottery.ruok.lottrey.activity.SearchGivePrizeActivity;
import com.lottery.ruok.lottrey.userInfo.UserInfo;

import io.rong.imkit.RongExtension;
import io.rong.imkit.plugin.IPluginModule;
import io.rong.imlib.model.Conversation;
import utils.Utils;

/**
 * Created by Beyond on 2016/11/14.
 */

/**
 * 大赏模块(+号 附加)
 */
public class PrizePlugin implements IPluginModule {

    private Context context;
    private Conversation.ConversationType conversationType;
    private String targetId;

    public PrizePlugin() {
    }

    //TODO 需要更好图标
    @Override
    public Drawable obtainDrawable(Context context) {
        return ContextCompat.getDrawable(context, R.drawable.icon_redpacket);
    }

    @Override
    public String obtainTitle(Context context) {
        return context.getString(R.string.prize_name);
    }

    /**
     * 点击扩展下面的icon
     *
     * @param currentFragment
     * @param extension
     */
    @Override
    public void onClick(Fragment currentFragment, RongExtension extension) {
        if(TextUtils.isEmpty(UserInfo.getToken())){
//            Utils.showToast("未登录,不能打赏");
            FragmentActivity activity = currentFragment.getActivity();
            activity.startActivity(new Intent(activity, LoginActivity.class));
            activity.overridePendingTransition(R.anim.anim_enter_from_bottom, R.anim.activity_stay);
        }else{
            context = currentFragment.getActivity();
            conversationType = extension.getConversationType();
            targetId = extension.getTargetId();
            SearchGivePrizeActivity.startActivity(context, targetId, conversationType);
        }


    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {

    }
}
